package com.lcn.controller;

import com.lcn.base.BaseInfoProperties;
import com.lcn.grace.result.GraceJSONResult;
import com.lcn.pojo.bo.NewFriendRequestBO;
import com.lcn.service.FriendRequestService;
import com.lcn.utils.PagedGridResult;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/friendRequest")
@Slf4j
public class FriendRequestController {

    @Resource
    private FriendRequestService friendRequestService;

    /**
     * 发起一个好友请求
     *
     * @param newFriendRequestBO
     * @return
     */
    @PostMapping("/add")
    public GraceJSONResult add(@RequestBody @Valid NewFriendRequestBO newFriendRequestBO) {
        friendRequestService.addNewRequest(newFriendRequestBO);
        return GraceJSONResult.ok();
    }

    /**
     * 分页查询历史好友请求
     *
     * @param userId
     * @param page
     * @param pageSize
     * @return
     */
    @PostMapping("/queryNew")
    public GraceJSONResult queryNew(String userId,
                                    @RequestParam(defaultValue = "1", name = "page") Integer page,
                                    @RequestParam(defaultValue = "10", name = "pageSize") Integer pageSize) {
        PagedGridResult pagedGridResult = friendRequestService.queryNewFriendList(userId, page, pageSize);
        return GraceJSONResult.ok(pagedGridResult);
    }

    /**
     * 通过好友请求
     *
     * @param friendRequestId
     * @param friendRemark
     * @return
     */
    @PostMapping("/pass")
    public GraceJSONResult pass(String friendRequestId, String friendRemark) {
        friendRequestService.pass(friendRequestId, friendRemark);
        return GraceJSONResult.ok();
    }

}
